package com.xing.dao;

import com.xing.core.BaseDao;
import com.xing.dto.BroadcastDTO;
import com.xing.entity.BroadcastEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2024/4/27 21:59
 */
@Mapper
public interface BroadcastDao extends BaseDao<BroadcastEntity> {
    @Select("SELECT *\n" +
            "FROM live_broadcast\n" +
            "WHERE room_id =\n" +
            "      (SELECT room_number\n" +
            "       FROM live_room\n" +
            "       WHERE anchor_id = #{userId}) AND del_flag = '0' LIMIT ${page},${limit}")
    public List<BroadcastDTO> getBroadcastByUserId(@Param("userId") Long userId,
                                                   @Param("page") Integer page,
                                                   @Param("limit") Integer limit);

    @Select("SELECT COUNT(*)\n" +
            "FROM live_broadcast\n" +
            "WHERE room_id =\n" +
            "      (SELECT room_number\n" +
            "       FROM live_room\n" +
            "       WHERE anchor_id = #{userId})")
    public Integer getLiveNumber(@Param("userId") Long userId);
}
